/* 
 * File:   dynarray.h
 * Author: Joni
 */
#ifndef DYNARRAY_H      
#define DYNARRAY_H

typedef struct dynarray {
    void** array;
    unsigned int top;
    unsigned int max_len;
} dynarray;

dynarray * da_new();

void da_free(dynarray * array);

_Bool da_append(dynarray * array, void* data);

void* da_remove(dynarray * array, unsigned int index);

void* da_get(dynarray * array, unsigned int index);

_Bool da_set(dynarray * array, unsigned int index, void* data);

int da_search(dynarray * array, void* find, int (*cmprf)(void*, void*));

int da_binsearch(dynarray * array, void* find, int left, int right, int (*cmprf)(void*, void*));

_Bool da_append_in(dynarray * array, void * data, unsigned int index);

int da_append_inorder(dynarray * array, void * data, int (*cmprf)(void*,void*), _Bool append_if_exists);

int da_binsearch_inorder_index(dynarray * array, void* find, int left, int right, int (*cmprf)(void*, void*));

void da_free_json(dynarray* da);

#endif /* DYNARRAY_H */
